# -*- coding: utf-8 -*-
# filename: handle.py

import web
import json
import time
from configcenter import configCenter
class prizeBegin(object):
    def GET(self):
        try:
            web.header("Access-Control-Allow-Origin", "*")
            web.header('content-type','text/json')
            cc = configCenter()
            config = cc.getConfig()
            host = config.get("global", "ip")
            port = config.get("global", "port")
            user = config.get("global", "user")
            pw = config.get("global", "password")
            database = config.get("global", "database")
            db = web.database(dbn='mysql', host=host, port=int(port), user=user, pw=pw, db=database)
            datadict = {}
            uptime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
            db.update('prize', where="id=1" , begintime=uptime)
            datadict['msg'] = "prize begin"
            datadict['result'] = 'true'
            return json.dumps(datadict)
        except Exception as e:
            return e.args
